#include("/template/common/layout/_page_layout.html")
#@layout()

#define css()
<style>

</style>
#end

#define js()
<!-- 加载编辑器的容器 -->
<script type="text/javascript" src="#(RESOURCE_HOST)/static/js/ueditor/ueditor.config.js"></script>

<script type="text/javascript" src="#(RESOURCE_HOST)/static/js/ueditor/ueditor.all.js"></script>
<!-- 配置文件 -->
<script type="text/javascript">
    var ue = UE.getEditor('container', {initialFrameHeight: 360});
    layui.use(['form', 'layer', 'upload'], function () {
        var form = layui.form
            , layer = layui.layer
            , $ = layui.jquery;

        form.on('submit(sub)', function (data) {
            var dataParam = $('#addForm').serializeArray();
            var newsletter = ue.getContentTxt().substring(0, 160) + "...";
            newsletter = newsletter.replace(/\s+/g, "");
            dataParam.push({"name": "model.content", "value": ue.getContent()});
            dataParam.push({"name": "model.newsletter", "value": newsletter});
            //alert(dataParam);
            util.sendAjax({
                type: 'POST',
                url: '#(ctxPath)/app/news/postAdd',
                data: dataParam,
                loadFlag: true,
                success: function (data) {
                    pop_close();
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        form.on('radio(pub_object)', function (data) {
            if (data.value == 0) {
                $("#character").hide();
                $("#individual").hide();
            } else if (data.value == 1) {
                $("#character").show();
                $("#individual").hide();
            } else {
                $("#character").hide();
                $("#individual").show();
            }
        });
    });
    $("#character").hide();
    $("#individual").hide();
</script>
#end

#define content()
<div class="x-body">
    <form class="layui-form layui-form-pane" action="" id="addForm">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">新闻标题</label>
                <div class="layui-input-block">
                    <input type="text" name="model.title" placeholder="请输入新闻标题" class="layui-input" style="width:1030px;">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">来源</label>
                <div class="layui-input-block">
                    <input name="model.source" id="source" autocomplete="off" class="layui-input" type="text">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">编辑</label>
                <div class="layui-input-inline">
                    <input name="model.editer" id="editer" autocomplete="off" class="layui-input" type="text">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">新闻类型</label>
                <div class="layui-input-block">
                    <select name="model.type" lay-filter="newsType" style="z-index: 2;">
                        <option value="0" selected="">政要文件</option>
                        <option value="1">跟踪动态</option>
                        <option value="2">最新政策</option>
                    </select>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">新闻内容</label>
            <div class="layui-input-block" style="z-index:1;">
                <script id="container" name="content" type="text/plain"></script>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">目标群体</label>
            <div class="layui-input-block">
                <input type="radio" name="model.isPublish" value="0" title="全体" lay-filter="pub_object" checked="">
                <input type="radio" name="model.isPublish" value="1" title="角色" lay-filter="pub_object">
                <input type="radio" name="model.isPublish" value="2" title="人群" lay-filter="pub_object">
            </div>
        </div>

        <div class="layui-form-item" id="character">
            <label class="layui-form-label">角色对象</label>
            <div class="layui-input-block">
                <select name="model.receiverRoles" lay-filter="character">
                    <option value=""></option>
                    #statusOption(roleStatus);
                </select>
            </div>
        </div>

        <div class="layui-form-item" id="individual">
            <label class="layui-form-label">个体对象</label>
            <div class="layui-input-block">
                <select name="model.receiverUsers" lay-filter="individual">
                    <option value=""></option>
                    #statusOption(personStatus);
                </select>
            </div>
        </div>

        <div class="layui-form-item layui-layer-btn-c">
            <button class="layui-btn" lay-filter="sub" lay-submit>提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </form>
</div>
#end